package com.zhengshang.web.controller.app;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhengshang.common.annotation.Log;
import com.zhengshang.common.core.controller.BaseController;
import com.zhengshang.common.core.domain.AjaxResult;
import com.zhengshang.common.enums.BusinessType;
import com.zhengshang.api.domain.AppAdvertisementRecord;
import com.zhengshang.api.service.IAppAdvertisementRecordService;
import com.zhengshang.common.utils.poi.ExcelUtil;
import com.zhengshang.common.core.page.TableDataInfo;

/**
 * APP用户观看广告记录Controller
 * 
 * @author zhengshang
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/app/advertisement")
public class AppAdvertisementRecordController extends BaseController
{
    @Autowired
    private IAppAdvertisementRecordService appAdvertisementRecordService;

    /**
     * 查询APP用户观看广告记录列表
     */
    @PreAuthorize("@ss.hasPermi('app:advertisement:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppAdvertisementRecord appAdvertisementRecord)
    {
        startPage();
        List<AppAdvertisementRecord> list = appAdvertisementRecordService.selectAppAdvertisementRecordList(appAdvertisementRecord);
        return getDataTable(list);
    }

    /**
     * 导出APP用户观看广告记录列表
     */
    @PreAuthorize("@ss.hasPermi('app:advertisement:export')")
    @Log(title = "APP用户观看广告记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppAdvertisementRecord appAdvertisementRecord)
    {
        List<AppAdvertisementRecord> list = appAdvertisementRecordService.selectAppAdvertisementRecordList(appAdvertisementRecord);
        ExcelUtil<AppAdvertisementRecord> util = new ExcelUtil<AppAdvertisementRecord>(AppAdvertisementRecord.class);
        return util.exportExcel(list, "advertisement");
    }

    /**
     * 获取APP用户观看广告记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:advertisement:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(appAdvertisementRecordService.selectAppAdvertisementRecordById(recordId));
    }

    /**
     * 新增APP用户观看广告记录
     */
    @PreAuthorize("@ss.hasPermi('app:advertisement:add')")
    @Log(title = "APP用户观看广告记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppAdvertisementRecord appAdvertisementRecord)
    {
        return toAjax(appAdvertisementRecordService.insertAppAdvertisementRecord(appAdvertisementRecord));
    }

    /**
     * 修改APP用户观看广告记录
     */
    @PreAuthorize("@ss.hasPermi('app:advertisement:edit')")
    @Log(title = "APP用户观看广告记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppAdvertisementRecord appAdvertisementRecord)
    {
        return toAjax(appAdvertisementRecordService.updateAppAdvertisementRecord(appAdvertisementRecord));
    }

    /**
     * 删除APP用户观看广告记录
     */
    @PreAuthorize("@ss.hasPermi('app:advertisement:remove')")
    @Log(title = "APP用户观看广告记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(appAdvertisementRecordService.deleteAppAdvertisementRecordByIds(recordIds));
    }
}
